<template>
  <div>
    <a-card
      style="width:100%;text-algin:center;"
      :tabList="tabList"
      :activeTabKey="key"
      @tabChange="go"
    >
      <span slot="customRender" slot-scope="item">
        <a-icon :type="item.icon"/>
      </span>

        <template v-show='key == "chat"'>
            <chat-list></chat-list>            
        </template>


    </a-card>
  </div>
</template>

<script>
import { Card, Icon } from "ant-design-vue";
import ChatList from '~/components/ChatList';

export default {
  components: {
    "a-card": Card,
    "a-icon": Icon,
    ChatList
  },
  data() {
    return {
      tabList: [
        {
          key: "chat",
          scopedSlots: { tab: "customRender" },
          icon: "message"
        },
        {
          key: "home",
          scopedSlots: { tab: "customRender" },
          icon: "home"
        }
      ],
      contentList: {
        tab1: "content1",
        tab2: "content2"
      },
      key: "",
      pathMap: {
        "/chat": "chat",
        "/home": "home"
      }
    };
  },
  methods: {
    go(key) {
      this.key = key;
    }
  },

  mounted() {
    this.key = this.pathMap[this.$route.path];
  }
};
</script>

<style lang="less" >
.ant-tabs-nav-container {
  text-align: center;
}
</style>

